<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/jquery-ztree/css/zTreeStyle/zTreeStyle.css">
</head>
<body>

	<ul id="tree" class="ztree"></ul>

	<script
		src="${pageContext.request.contextPath}/static/js/common/jquery-1.11.0.min.js"></script>
	<script
		src="${pageContext.request.contextPath}/static/jquery-ztree/js/jquery.ztree.all.min.js"></script>
	<script>
    $(function () {
        var setting = {
            data: {
                simpleData: {
                    enable: true
                }
            },
            callback : {
                onClick : function(event, treeId, treeNode) {
                	if (treeNode.uri.indexOf("http") > -1) {
                        parent.frames['content'].location.href = treeNode.uri;
                	} else if (treeNode.uri.length > 0) {
                        parent.frames['content'].location.href = "${pageContext.request.contextPath}/" + treeNode.uri;
                	}
                }
            }
        };

        var zNodes =[
            <c:forEach items="${menuList}" var="o">
                { id:${o.resource_id}, pId:${o.parent_id}, name:"${o.resource_name}", uri:"${o.resource_request_uri}", open:${o.parent_id == 0}},
            </c:forEach>
        ];

        $(document).ready(function(){
            $.fn.zTree.init($("#tree"), setting, zNodes);
        });
    });
</script>
</body>
</html>